// VideoPlayer.h: interface for the CVideoPlayer class.
//
//////////////////////////////////////////////////////////////////////
#ifdef VC70

#if !defined(AFX_VIDEOPLAYER_H__4CEF2F0C_0224_4854_9614_71E736E09D72__INCLUDED_)
#define AFX_VIDEOPLAYER_H__4CEF2F0C_0224_4854_9614_71E736E09D72__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define COMMAND_NONE	0
#define COMMAND_PLAY	1
#define COMMAND_STOP	2
#define COMMAND_PAUSE	3
#define COMMAND_REWIND	4
#define COMMAND_FAST	5
#define COMMAND_BEGIN	6
#define COMMAND_END		7
#define COMMAND_SEEK	8

#include "../Common/RMSThread.h"
#include "../RMSLib/clientinterface.h"
#include "RMSWaveClientSocket.h"

class CVideoPlayer : public CRMSThread,
					 public ClientAccess,
					 public CWaveSync
{
public:
	DWORD GetMode();
	int m_nFastSpeed;
	BOOL RewindStep(int nMaxStep);
	BOOL SeekFromFile(fpos_t position);
	BOOL FastForwardStep(int nMaxStep);
	DWORD m_dwCommand;
	void SetMode(DWORD dwCommand);
	DWORD StopPlayer(BOOL bCritical = FALSE);
	DWORD StartPlayer(int nW, int nH);

	fpos_t m_lTotalStoredData;
	fpos_t m_lCurrentStoredData;
	fpos_t m_lCurrentPlayData;
	fpos_t m_lNewPlayData;
	int m_nFrameRate;
	int m_nCurrentFrameRate;
	int m_nBitrate;
	int m_nW;
	int m_nH;

	int m_nCamera;

	CVideoPlayer();
	virtual ~CVideoPlayer();

protected:
	FILE* m_file;
	CSingleLock *slFile;

	TimeMark m_timeCurrent;

	BYTE* m_pData;

	DWORD ThreadFunc();
	DWORD OnTerminate();

private:
	DWORD m_dwOldCommand;
	BOOL GetFrameFromFile();
	DWORD WaitForRefresh();

	DWORD timeBegin;
	DWORD timeEnd;
	DWORD timeFrame;
	DWORD dwDelta;
	int nFPS;

	int m_nTotalSteps;
	char m_szTime[50];
	char m_szDate[50];

	fpos_t m_lTotalPlayData;

	BYTE m_AudioData[PACKET_SIZE*100*2];
	BYTE* m_pAudio[2];
	int m_flip;

	void outAudio(BYTE* pSrc, int szAudio);
};

#endif // !defined(AFX_VIDEOPLAYER_H__4CEF2F0C_0224_4854_9614_71E736E09D72__INCLUDED_)

#endif //def VC70
